package com.spark.lola.service.gds.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spark.lola.entity.gds.CategoryInfo;
import com.spark.lola.entity.gds.ProductInfo;
import com.spark.lola.mapper.gds.CategoryInfoMapper;
import com.spark.lola.service.gds.ICategoryInfoService;
import com.spark.lola.support.common.constant.CommonConstant;
import com.spark.lola.support.core.vo.SelectMap;
import com.spark.lola.support.mybatis.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dengyejun
 * @since 2020-04-27
 */
@Service
public class CategoryInfoServiceImpl extends BaseServiceImpl<CategoryInfoMapper, CategoryInfo> implements ICategoryInfoService {

    @Override
    public List<SelectMap> selectMap() {
        QueryWrapper<CategoryInfo> queryWrapper =new QueryWrapper<>();
        queryWrapper.select("id,name");
        queryWrapper.eq("used", CommonConstant.Y);

        List<CategoryInfo> lst = baseMapper.selectList(queryWrapper);
        List<SelectMap> selectMaps =new ArrayList<>();
        if(!CollectionUtils.isEmpty(lst)) {
            lst.forEach(item -> {
                selectMaps.add(new SelectMap(item.getId(), item.getName()));
            });
        }
        return selectMaps;    }
}
